package com.own.business.question.entity.dto;

import com.own.business.question.common.base.ReplyEnvironment;
import com.own.business.question.entity.bo.PracticeBo;
import com.own.component.common.base.entity.BaseDto;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * PracticeDto
 *
 * @author 陈学礼 （你是一段成熟的代码，要学会自己改bug）
 * @version 4.0.0
 * @date 2021/05/14 15:49:28
 * @since 4.0.0
 */
@Schema(description = "练习表" + ConstantBeanSuffix.DTO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class PracticeDto extends BaseDto<PracticeBo> {

    @Schema(description = "目标内容id")
    private Long targetId;

    @Schema(description = "用户id")
    private Long userId;

    @Schema(description = "题目数量")
    private Integer questionNumber;

    @Schema(description = "作答环境")
    private ReplyEnvironment replyEnvironment;

    @Schema(description = "作答状态 0=未作答 1=已作答 2=保存 3=废弃")
    private Integer status;

    @Schema(description = "用时（ms）")
    private Long useTime;

    @Schema(description = "分数")
    private BigDecimal score;

    @Schema(description = "获取练习的时间")
    private LocalDateTime refreshTime;

    @Schema(description = "提交练习的时间")
    private LocalDateTime submitTime;

    /**
     * 转业务层对象
     *
     * @param entity 原业务层对象
     * @return 业务层对象
     */
    @Override
    public PracticeBo toBo(PracticeBo entity) {
        if (entity == null) {
            entity = new PracticeBo();
        }
        entity.setTargetId(targetId);
        entity.setUserId(userId);
        entity.setQuestionNumber(questionNumber);
        entity.setReplyEnvironment(replyEnvironment);
        entity.setStatus(status);
        entity.setUseTime(useTime);
        entity.setScore(score);
        entity.setRefreshTime(refreshTime);
        entity.setSubmitTime(submitTime);
        return super.toBo(entity);
    }

}
